<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">&quot;use strict&quot;;
Object.defineProperty(exports, &quot;__esModule&quot;, { value: true });
exports.AbstractMatch = void 0;
<span id='Autolinker-match-AbstractMatch'>/**
</span> * @abstract
 * @class Autolinker.match.AbstractMatch
 *
 * Represents a match found in an input string which should be Autolinked. A Match object is what is provided in a
 * {@link Autolinker#replaceFn replaceFn}, and may be used to query for details about the match.
 *
 * For example:
 *
 *     var input = &quot;...&quot;;  // string with URLs, Email Addresses, and Mentions (Twitter, Instagram, Soundcloud)
 *
 *     var linkedText = Autolinker.link( input, {
 *         replaceFn : function( match ) {
 *             console.log( &quot;href = &quot;, match.getAnchorHref() );
 *             console.log( &quot;text = &quot;, match.getAnchorText() );
 *
 *             switch( match.getType() ) {
 *                 case &#39;url&#39; :
 *                     console.log( &quot;url: &quot;, match.getUrl() );
 *
 *                 case &#39;email&#39; :
 *                     console.log( &quot;email: &quot;, match.getEmail() );
 *
 *                 case &#39;mention&#39; :
 *                     console.log( &quot;mention: &quot;, match.getMention() );
 *             }
 *         }
 *     } );
 *
 * See the {@link Autolinker} class for more details on using the {@link Autolinker#replaceFn replaceFn}.
 */
var AbstractMatch =  (function () {
<span id='Autolinker-match-Match-method-constructor'>    /**
</span>     * @member Autolinker.match.Match
     * @method constructor
     * @param {Object} cfg The configuration properties for the Match
     *   instance, specified in an Object (map).
     */
    function AbstractMatch(cfg) {
<span id='Autolinker-match-AbstractMatch-cfg-tagBuilder'>        /**
</span>         * @cfg {Autolinker.AnchorTagBuilder} tagBuilder (required)
         *
         * Reference to the AnchorTagBuilder instance to use to generate an anchor
         * tag for the Match.
         */
        // @ts-ignore
        this._ = null; // property used just to get the above doc comment into the ES5 output and documentation generator
<span id='Autolinker-match-AbstractMatch-cfg-matchedText'>        /**
</span>         * @cfg {String} matchedText (required)
         *
         * The original text that was matched by the {@link Autolinker.matcher.Matcher}.
         */
        this.matchedText = &#39;&#39;; // default value just to get the above doc comment in the ES5 output and documentation generator
<span id='Autolinker-match-AbstractMatch-cfg-offset'>        /**
</span>         * @cfg {Number} offset (required)
         *
         * The offset of where the match was made in the input string.
         */
        this.offset = 0; // default value just to get the above doc comment in the ES5 output and documentation generator
        this.tagBuilder = cfg.tagBuilder;
        this.matchedText = cfg.matchedText;
        this.offset = cfg.offset;
    }
<span id='Autolinker-match-AbstractMatch-method-getMatchedText'>    /**
</span>     * Returns the original text that was matched.
     *
     * @return {String}
     */
    AbstractMatch.prototype.getMatchedText = function () {
        return this.matchedText;
    };
<span id='Autolinker-match-AbstractMatch-method-setOffset'>    /**
</span>     * Sets the {@link #offset} of where the match was made in the input string.
     *
     * A {@link Autolinker.matcher.Matcher} will be fed only HTML text nodes,
     * and will therefore set an original offset that is relative to the HTML
     * text node itself. However, we want this offset to be relative to the full
     * HTML input string, and thus if using {@link Autolinker#parse} (rather
     * than calling a {@link Autolinker.matcher.Matcher} directly), then this
     * offset is corrected after the Matcher itself has done its job.
     *
     * @private
     * @param {Number} offset
     */
    AbstractMatch.prototype.setOffset = function (offset) {
        this.offset = offset;
    };
<span id='Autolinker-match-AbstractMatch-method-getOffset'>    /**
</span>     * Returns the offset of where the match was made in the input string. This
     * is the 0-based index of the match.
     *
     * @return {Number}
     */
    AbstractMatch.prototype.getOffset = function () {
        return this.offset;
    };
<span id='Autolinker-match-AbstractMatch-method-getCssClassSuffixes'>    /**
</span>     * Returns the CSS class suffix(es) for this match.
     *
     * A CSS class suffix is appended to the {@link Autolinker#className} in
     * the {@link Autolinker.AnchorTagBuilder} when a match is translated into
     * an anchor tag.
     *
     * For example, if {@link Autolinker#className} was configured as &#39;myLink&#39;,
     * and this method returns `[ &#39;url&#39; ]`, the final class name of the element
     * will become: &#39;myLink myLink-url&#39;.
     *
     * The match may provide multiple CSS class suffixes to be appended to the
     * {@link Autolinker#className} in order to facilitate better styling
     * options for different match criteria. See {@link Autolinker.match.Mention}
     * for an example.
     *
     * By default, this method returns a single array with the match&#39;s
     * {@link #getType type} name, but may be overridden by subclasses.
     *
     * @return {String[]}
     */
    AbstractMatch.prototype.getCssClassSuffixes = function () {
        return [this.type];
    };
<span id='Autolinker-match-AbstractMatch-method-buildTag'>    /**
</span>     * Builds and returns an {@link Autolinker.HtmlTag} instance based on the
     * Match.
     *
     * This can be used to easily generate anchor tags from matches, and either
     * return their HTML string, or modify them before doing so.
     *
     * Example Usage:
     *
     *     var tag = match.buildTag();
     *     tag.addClass( &#39;cordova-link&#39; );
     *     tag.setAttr( &#39;target&#39;, &#39;_system&#39; );
     *
     *     tag.toAnchorString();  // &lt;a href=&quot;http://google.com&quot; class=&quot;cordova-link&quot; target=&quot;_system&quot;&gt;Google&lt;/a&gt;
     *
     * Example Usage in {@link Autolinker#replaceFn}:
     *
     *     var html = Autolinker.link( &quot;Test google.com&quot;, {
     *         replaceFn : function( match ) {
     *             var tag = match.buildTag();  // returns an {@link Autolinker.HtmlTag} instance
     *             tag.setAttr( &#39;rel&#39;, &#39;nofollow&#39; );
     *
     *             return tag;
     *         }
     *     } );
     *
     *     // generated html:
     *     //   Test &lt;a href=&quot;http://google.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;google.com&lt;/a&gt;
     */
    AbstractMatch.prototype.buildTag = function () {
        return this.tagBuilder.build(this);
    };
    return AbstractMatch;
}());
exports.AbstractMatch = AbstractMatch;
//# sourceMappingURL=abstract-match.js.map</pre>
</body>
</html>
